// Michael Depuy
// depuym@onid.orst.edu
// CS311-400
// Homework 2


#include <stdio.h>
#include <getopt.h>
#include <sys/utsname.h>
#include <time.h>
#include <sys/stat.h>
#include <unistd.h>

int main(int argc, char** argv){
  
  char c;
  struct utsname uname_pointer;
  time_t time_raw_format;
  struct stat s;
  int opt;
  
  while((opt = getopt(argc, argv, "htf:")) != -1){
      switch(opt){
      case 'h':
	uname(&uname_pointer);
	printf("Hostname = %s \n", uname_pointer.nodename);
	break;
      case 't':
	time(&time_raw_format);
	printf("The current local time: %s", ctime(&time_raw_format));
	break;
      case 'f':
	if(stat(optarg, &s) == 0){
	  printf("size of file '%s' is %d bytes\n", optarg, (int)s.st_size);
	}
	else{
	  printf("file '%s' is not found\n", optarg);
	}
	break;
      }
    }
    return 0;
}
